<template>
    <div>
        <el-table :data="list" style="width: 100%" max-height="500">
            <el-table-column fixed prop="hotels.hotelId" label="酒店ID" width="150">
            </el-table-column>
            <el-table-column prop="hotels.hotelName" label="酒店名" width="120">
            </el-table-column>
            <el-table-column prop="hotels.hotelTelephone" label="电话" width="120">
            </el-table-column>
            <el-table-column prop="hotels.hotelPrice" label="房间最低单价" width="120" :formatter="formatRole">
            </el-table-column>
            <el-table-column prop="hotels.hotelLabel" label="酒店标签" width="120">
            </el-table-column>
            <el-table-column prop="hotels.hotelLng" label="经度" width="120">
            </el-table-column>
            <el-table-column prop="hotels.hotelLat" label="纬度" width="120">
            </el-table-column>
            <el-table-column prop="hotels.hotelAddr" label="结构化地址" width="120" show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="hotels.province" label="省" width="120">
            </el-table-column>
            <el-table-column prop="hotels.city" label="市" width="120">
            </el-table-column>
            <el-table-column prop="hotels.area" label="区" width="120">
            </el-table-column>
            <el-table-column prop="hotels.overallRating" label="总评分" width="120">
            </el-table-column>


            <!-- 假审核 -->
            <el-table-column fixed="right" label="审核状态" width="120">
                <!-- <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                </template> -->
                
                <template slot-scope="scope" >
                    <el-button size="mini" type="info" v-if="scope.row.hotels.hotelId % 3  == 0">未审核</el-button>
                    <el-button size="mini" type="danger" v-else-if="scope.row.hotels.hotelId % 3  == 1">未通过</el-button>
                    <el-button size="mini" type="success" v-else>已通过</el-button>
                </template>

            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="pageDto.page" :page-sizes="[5, 10, 20, 30, 50]" :page-size="pageDto.size"
                layout="total, sizes, prev, pager, next, jumper" :total="100">
            </el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    name: "hoteltable",
    data() {
        return {
            pageDto: { page: 1, size: 10, hotels: {} },
            list: [],
            displayList: [],
        }
    },
    methods: {
        // element ui
        // 分页
        handleSizeChange(val) {
            this.pageDto.size = val;
            this.queryByPage();
        },
        handleCurrentChange(val) {
            this.pageDto.page = val;
            this.queryByPage();
        },
        // 删除
        handleDelete(row) {
            this.$api.hotelsApi.deleteById({ hotelId: row.hotels.hotelId }).then(res => {
                if (res.data.code == 1) {
                    this.$notify({
                        title: "成功",
                        message: "数据删除成功！",
                        type: "success",
                    });
                } else {
                    this.$notify.error({
                        title: "错误",
                        message: "数据删除失败！",
                    });
                }
            })
            this.queryByPage();
        },

        // 请求参数
        queryByPage() {
            this.$api.hotelsApi.queryByPage(this.pageDto).then(res => {
                this.list = res.data.data;
                // this.displayList = this.list.map(item=>item.users)
                // console.log(this.displayList);
            })
        },
    },
    mounted() {
        this.queryByPage();
    },
}
</script>